package cn.stylefeng.guns.modular.lx.controller;

import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo;
import cn.stylefeng.guns.modular.hx.storage.entity.HxStorageOut;
import cn.stylefeng.guns.modular.hx.storage.model.params.HxStorageCenterParam;
import cn.stylefeng.guns.modular.lx.entity.LxSpYsy;
import cn.stylefeng.guns.modular.lx.model.params.LxSpYsyParam;
import cn.stylefeng.guns.modular.lx.service.LxSpYsyService;
import cn.stylefeng.guns.sys.modular.system.entity.User;
import cn.stylefeng.roses.core.base.controller.BaseController;
import cn.stylefeng.roses.core.reqres.response.ResponseData;
import cn.stylefeng.guns.sys.modular.system.service.UserService;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;


/**
 * 控制器
 *
 * @author 尹思莹
 * @Date 2023-12-01 17:36:29
 */
@Controller
@RequestMapping("/lxSpYsy")
public class LxSpYsyController extends BaseController {

    private String PREFIX = "/lx/lxSpYsy";

    @Autowired
    private LxSpYsyService lxSpYsyService;

    @Autowired
    private UserService userService;

    /**
     * 跳转到主页面
     *
     * @author 尹思莹
     * @Date 2023-12-01
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "/lxSpYsy.html";
    }

    /**
     * 新增页面
     *
     * @author 尹思莹
     * @Date 2023-12-01
     */
    @RequestMapping("/add")
    public String add() {
        return PREFIX + "/lxSpYsy_add.html";
    }

    /**
     * 编辑页面
     *
     * @author 尹思莹
     * @Date 2023-12-01
     */
    @RequestMapping("/edit")
    public String edit() {
        return PREFIX + "/lxSpYsy_edit.html";
    }

    @RequestMapping("/buy")
    public String buy() {return PREFIX + "/lxSpYsy_buy.html";}
    /**
     * 新增接口
     *
     * @author 尹思莹
     * @Date 2023-12-01
     */
    @RequestMapping("/addItem")
    @ResponseBody
    public ResponseData addItem(LxSpYsyParam lxSpYsyParam) {
        this.lxSpYsyService.add(lxSpYsyParam);
        return ResponseData.success();
    }

    /**
     * 编辑接口
     *
     * @author 尹思莹
     * @Date 2023-12-01
     */
    @RequestMapping("/editItem")
    @ResponseBody
    public ResponseData editItem(LxSpYsyParam lxSpYsyParam) {
        this.lxSpYsyService.update(lxSpYsyParam);
        return ResponseData.success();
    }

    /**
     * 删除接口
     *
     * @author 尹思莹
     * @Date 2023-12-01
     */
    @RequestMapping("/delete")
    @ResponseBody
    public ResponseData delete(LxSpYsyParam lxSpYsyParam) {
        this.lxSpYsyService.delete(lxSpYsyParam);
        return ResponseData.success();
    }

    /**
     * 查看详情接口
     *
     * @author 尹思莹
     * @Date 2023-12-01
     */
    @RequestMapping("/detail")
    @ResponseBody
    public ResponseData detail(LxSpYsyParam lxSpYsyParam) {
        LxSpYsy detail = this.lxSpYsyService.getById(lxSpYsyParam.getSpId());
        return ResponseData.success(detail);
    }

    /**
     * 查询列表
     *
     * @author 尹思莹
     * @Date 2023-12-01
     */
    @ResponseBody
    @RequestMapping("/list")
    public LayuiPageInfo list(LxSpYsyParam lxSpYsyParam,String condition ) {
        return this.lxSpYsyService.findPageBySpec(lxSpYsyParam,condition);
    }


    @ResponseBody
    @RequestMapping("/update")
    public ResponseData update(String spName,String spChl) {
        //System.out.println(spChl);
        //System.out.println(spName);
        LxSpYsyParam lxSpYsyParam=new LxSpYsyParam();
        lxSpYsyParam.setSpChl(spChl);
        lxSpYsyParam.setSpName(spName);

        this.lxSpYsyService.update1(lxSpYsyParam);
        return ResponseData.success();
    }
}


